Socket
Socket
Sign inDemoInstall

@metamask/json-rpc-engine

Package Overview
Dependencies
Maintainers
12
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/json-rpc-engine

A tool for processing JSON-RPC messages


Version published
Weekly downloads
109K
decreased by-60.07%
Maintainers
12
Weekly downloads
 
Created

What is @metamask/json-rpc-engine?

@metamask/json-rpc-engine is a library for creating and managing JSON-RPC middleware stacks. It is particularly useful for building JSON-RPC servers and clients, and it provides a flexible way to handle JSON-RPC requests and responses.

What are @metamask/json-rpc-engine's main functionalities?

Creating a JSON-RPC Engine

This feature allows you to create a new JSON-RPC engine instance, which can be used to manage middleware and handle JSON-RPC requests.

const { JsonRpcEngine } = require('@metamask/json-rpc-engine');
const engine = new JsonRpcEngine();

Adding Middleware

This feature allows you to add middleware to the JSON-RPC engine. Middleware can inspect and modify requests and responses, or terminate the request handling.

engine.push((req, res, next, end) => {
  if (req.method === 'test_method') {
    res.result = 'test_result';
    return end();
  }
  next();
});

Handling Requests

This feature allows you to handle JSON-RPC requests using the engine. The engine processes the request through the middleware stack and returns the response.

const request = { id: 1, jsonrpc: '2.0', method: 'test_method' };
engine.handle(request, (err, res) => {
  if (err) {
    console.error(err);
  } else {
    console.log(res);
  }
});

Other packages similar to @metamask/json-rpc-engine

Keywords

FAQs

Package last updated on 04 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc